/**
 * Creat by TanLei
 * Description:
 * User:86183
 * Date:2022-05-11
 * Time:11:57
 */
public class Demo8 {
    public static void serial(){
        long begin = System.currentTimeMillis();
        long a = 0;
        for(int i=0;i < 10_0000_0000;i++){
            a++;
        }
        long b = 0;
        for(int i=0;i < 10_0000_0000;i++){
            b++;
        }
        long end = System.currentTimeMillis();
        System.out.println("消耗时间："+(end-begin)+"ms");
    }

    public static void concurrency() throws InterruptedException {
        long begin = System.currentTimeMillis();
        Thread thread1 = new Thread(()->{
            long a = 0;
            for(long i=0;i<10_0000_0000;i++){
                a++;
            }
        });
        thread1.start();

        Thread thread2 = new Thread(()->{
            long b = 0;
            for(long i=0;i<10_0000_0000;i++){
                b++;
            }
        });
        thread2.start();

        thread1.join();
        thread2.join();

        long end = System.currentTimeMillis();
        System.out.println("消耗时间："+(end-begin)+"ms");
    }

    public static void main(String[] args) throws InterruptedException {
        serial();
        concurrency();
    }
}
